package lab02.test26;

import java.util.Scanner;
/**
 * Created by dell on 2017/11/2.
 */
public class ExceptionTest {
    public static void main(String[] args) {
        //在main方法中使用try、catch、finally
        int a = 0;
        int b = 0;

        while (true) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("please input 1st:");
            a = scanner.nextInt();
            System.out.println("please input 2nd：");
            b = scanner.nextInt();
            int c = 0;
            try {
                c = a / b;
            } catch (ArithmeticException e) {
                System.out.println("除数为0！");
            } finally {
                System.out.println("最后都会执行的语句！");
            }
            System.out.println(a + "/" + b + "=" + c);
        }
    }
}
